<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div {
            width: 400px;
            height: 400px;
            background-color: aqua;
        }
    </style>
</head>

<body>
    <div class="box"></div>
    <script>
        const box = document.querySelector('div')
        box.addEventListener('mouseenter', function () {
            console.log('鼠标经过了');
        })
        box.addEventListener('mouseleave', function () {
            console.log('鼠标离开了');
        })   
    </script>
</body>

</html>